<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_member.*" %>
<%@page import="com.lmpop.trade.ti_company.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.trade.ts_custclass.*" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.trade.ts_area.*" %>
<%@page import="com.lmpop.updateHtml.parseXml.Config"%>
<%@page import="com.lmpop.trade.ti_custlevel.Ti_custlevelInfo" %>
<%@page import="java.io.File"%> 
<%
	request.setCharacterEncoding("UTF-8");
	String req_url=request.getHeader("Referer");
	Map ti_member = new Hashtable();
	String s_cust_name = "";
	if(request.getParameter("s_cust_name")!=null && !request.getParameter("s_cust_name").equals("")){
		s_cust_name = request.getParameter("s_cust_name");
		ti_member.put("cust_name",s_cust_name);
	}
	String s_user_class = "";
	if(request.getParameter("s_user_class")!=null && !request.getParameter("s_user_class").equals("")){
		s_user_class = request.getParameter("s_user_class");
		ti_member.put("user_class",s_user_class);
	}	
		
	
	String req_in_date2 = "";
	if(request.getParameter("req_in_date2")!=null && !request.getParameter("req_in_date2").equals("")){
		req_in_date2 = request.getParameter("req_in_date2");
		ti_member.put("cust_oper_date2",req_in_date2);
	}
	
	String s_area_attr = "";
	if(request.getParameter("area_attr")!=null && !request.getParameter("area_attr").equals("")){
		s_area_attr = request.getParameter("area_attr");
		ti_member.put("area_attr",s_area_attr);
		}
		
	Ti_custlevelInfo custlevelinfo = new Ti_custlevelInfo();
	Ti_companyInfo companyInfo=new Ti_companyInfo();		
	
	
    ti_member.put("cust_type","0");	
	ti_member.put("m_state","1");	
	Ti_memberInfo ti_memberInfo = new Ti_memberInfo();
	Map custclassinfoMap = new Hashtable();
	Ts_custclassInfo custclassinfo = new Ts_custclassInfo();
	custclassinfoMap.put("class_type","0");
	String custclass_select =  custclassinfo.getSelectString(custclassinfoMap,"");
	
	String iStart = "0";
	int limit = 20;
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
	String state = tb_commparaInfo.getSelectItem("39","");     
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_memberInfo.getListByPageCom(ti_member,Integer.parseInt(iStart),limit);
	int counter = ti_memberInfo.getCountByObjCom(ti_member);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?s_user_class="+s_user_class+"&area_attr="+s_area_attr+"&req_in_date2="+req_in_date2+"&iStart=",Integer.parseInt(iStart),limit);
   
    Ts_areaInfo ts_areaInfo = new Ts_areaInfo();
	Map areaMap  = ts_areaInfo.getAreaClass();
	%>
<html>
  <head>
    
    <title>企业商铺管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<metahttp-equivmetahttp-equiv="x-ua-compatible" content="ie=7"/> 
	<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js"></script>	
	<script type="text/javascript" src="index.js"></script>
	<script>	  setstartProvince('');	  </script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="80%">
				<h1>企业商铺管理</h1>
			</td>
			<!--td>
			    <a href="addCompanyInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td-->
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--
	<table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>-----------------</h4>
		  <span>1----------------。</span><br/>
		  <span>2----------------。</span>
		  </td>
        </tr>
      </table>
      <br/>
	  -->
	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
					按会员名称:<input name="s_cust_name" type="text" />
				
			<!--	按会员类型:<select name="s_cust_type" >
									<option value="">请选择</option>
									<option value="0">企业</option>
									<option value="1">个人</option>
									</select>
			-->	

             按所在地区:			

				<select name="province" id="province" onclick="setCitys(this.value)">
				  <option value="">省份</option> 
				</select>
				<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
				  <option value="">地级市</option> 
				 </select>
				<select name="city_code" id="city_code" style="display:inline" >
				 <option value="">市、县级市、县</option> 
				</select>
					<input type="hidden" name="area_attr_bak" id="area_attr_bak" value="" />
					<input type="hidden" name="area_attr" id="area_attr" value="" />
					
				<br>
			    按注册时间:<input name="req_in_date1" type="text" id="req_in_date1" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'req_in_date2\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
								~
							 <input name="req_in_date2" id="req_in_date2" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'req_in_date1\',{d:1})}',readOnly:true})" size="15" width="150px"/>
				按会员等级:<select name="s_user_class" >
									<option value="">请选择</option>
									<%=custclass_select%>
									</select>			
				<input name="searchInfo" type="button" value="查询" onclick="searcher();"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
 
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>会员名称</th>
		  	<th>会员所在地</th>
		  	 
		   
		  	
		  	<th>会员等级</th>
		  	
		  	<th>注册时间</th>
			
	  		<th width="20%">操作</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String cust_id="",cust_name="",cust_type="",area_attr="",state_code="",user_class="",reg_date="";
					String cust_class_name="",e="",f="",g="",by1="",short_name="";
		  			  	if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
						if(map.get("cust_name")!=null) cust_name = map.get("cust_name").toString();
						 
						if(map.get("cust_type")!=null) cust_type = map.get("cust_type").toString();
						if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
						if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
						if(map.get("user_class")!=null) user_class = map.get("user_class").toString();
						if(map.get("reg_date")!=null) reg_date = map.get("reg_date").toString();
						 
						if(map.get("by1")!=null) by1 = map.get("by1").toString();
						if(reg_date.length()>10)reg_date=reg_date.substring(0,10);
						
						StringBuffer stateoutput =new StringBuffer();
						if(!area_attr.equals(""))
							{
							  String chIds[] =	area_attr.split("\\|");	
							  for(String chId:chIds)
							  {
								 if(areaMap!=null)
								 {
									 if(areaMap.get(chId)!=null)
									 {
										stateoutput.append("<a href='index.jsp?area_attr="+chId+"'>"+areaMap.get(chId).toString()+"</a> ");                 
									  }                  
								 
								  }                 
							   }		    
							}
						if(map.get("e")!=null) e = map.get("e").toString();
						if(map.get("f")!=null) f = map.get("f").toString();
						if(map.get("g")!=null) g = map.get("g").toString();
						
					//a：未审核 b：审核未通过 c：正常/审核通过 d：禁用
			
					cust_class_name = custclassinfo.getcust_class_name(user_class);
					if (custlevelinfo.checkCustLevel(cust_id).equals("1")) cust_class_name = cust_class_name+"<font style=color:red>[ 已过期 ]</font>";
					
					String cust_type_string = "企业";
					String updatePage = "updateCompanyInfo.jsp";
					if(cust_type.equals("1")){
						cust_type_string="个人";
						updatePage = "updatePersonalInfo.jsp";
					}
					short_name = companyInfo.getShortNameByPk(cust_id);
					if (short_name.equals("")) short_name = cust_id;
					Config cfg=new Config();
					String root_path=cfg.getString("rootpath");	
				 	File file = new File(root_path+"/data/company/"+short_name+"/index.html");
				 	if (user_class.equals("1"))  file = new File(root_path+"/templets/company/web/"+cust_id+"/index.jsp"); 
				 	
				 	
 					String host = request.getHeader("host");
					String basePath = host.substring(host.indexOf(".")+1,host.length()-5);
		%>		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=cust_id %>" /></td>
			
		  	<td><a href="/data/company/<%=cust_id%>/index.html" target="_blank"><%=cust_name%></a></td>
		  	<td><%=stateoutput%></td>
			 
			<!--
		  	<td><a href="index.jsp?s_cust_type=<%=cust_type%>"><%=cust_type_string%></a></td>
		  	-->
		  	 
		  	
		  	<td><%=cust_class_name%></td>
		  	
		  	<td><%=reg_date%></td>
			<td width="50%">
					<%
						if (!file.exists())
						{ 		
							if(user_class.equals("1"))
							{
						%>
		  	    <p><input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="开通批发平台" /> </p>          
		  	    <%
		  	    	}
		  	    	else if (user_class.equals("2"))
		  	    	{
		  	    %>
		  	    <p><input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="开通零售商铺" /> </p>          
		  	    <%
		  	    	}
		  	    	else
		  	    	{
		  	    %>
		  	    <p><input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="开通普通会员网站"  />  </p> 
	 					<%
	 						}
 						}
 						else
 						{
 							
 					%> 		
 					<p>点击查看：<a href="http://<%=short_name%>.<%=basePath%>" target="_blank" style="font-size:14px;font-weight:bold;color:blue">http://<%=short_name%>.<%=basePath%></a></p>			 
 					 <p>	
 					 	<input type="button" name="delInfo" onClick="deletejs('<%=cust_id %>')" value="关闭网站" class="buttab" />  
 						<%
 						if(user_class.equals("1"))
						{
						%>
		  	    <input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="重新开通" class="buttab" />   </p>       
		  	    <%
		  	    	}
		  	    	else if (user_class.equals("2"))
		  	    	{
		  	    %>
		  	    <p><input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="重新开通" /> </p>          
		  	    <%
		  	    	}
		  	    	else
		  	    	{
		  	    %>
		  	    <input type="button" name="delInfo" onClick="tijiao('<%=cust_id %>','/templets/company/templets/<%=user_class%>/default/')" value="重新开通" class="buttab" />   </p>
		  	   
	 					<%
	 						}
	 					
 						}
 					%>
	  		  &nbsp;
	  			<div id="backMessage<%=cust_id %>"></div>
	  		</td>
			
			
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">

			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="5779" />
	  </form>
</body>

</html>
